module math

    implicit none

contains

    integer pure function max(x, y) result(z)  !! 函数：判断两值最大值
        integer, intent(in) :: x, y

        if (x > y) then
            z = x
        else
            z = y
        end if

    end function max

    pure subroutine get_max(x, y, z)  !! 子例程：判断两值最大值
        integer, intent(in) :: x, y
        integer, intent(out) :: z

        if (x > y) then
            z = x
        else
            z = y
        end if

    end subroutine get_max

end module math

program function

    use math, only: max, get_max
    implicit none

    integer :: z
    print *, max(1, 2)
    call get_max(1, 2, z)
    print *, z  ! 与max(1,2)一样

end program function
!>            2
!>            2